import React, { Component } from 'react';
import { connect } from 'dva';
import dataTableCreate from '../../addons/DataTable';
import * as com from '../../../utils/common';

const daoName = "LSCKDE";
const columns = [
  { title: '客户名称', width: 120, sorter: false, dataIndex: 'CUNM', key: 'CUNM', dispaly: true, filter: false, },
  { title: '存款余额', width: 130, sorter: true, dataIndex: 'ACBL', className: 'column-money', render: data => com.formatNumber(data/10000), key: 'ACBL', dispaly: true, canEdit: true, filter: false, },
  { title: '较上日', width: 130, sorter: true, dataIndex: 'JSR', className: 'column-money', render: data => com.formatNumber(data/10000), key: 'JSR', dispaly: true, canEdit: true, filter: false, },
  // { title: '较年初', width: 130, sorter: true, dataIndex: 'JNC', className: 'column-money', render: data => com.formatNumber(data), key: 'JNC', dispaly: true, canEdit: true, filter: false, },
  // { title: '年日均', width: 130, sorter: true, dataIndex: 'AVVL', className: 'column-money', render: data => com.formatNumber(data), key: 'AVVL', dispaly: true, canEdit: true, filter: false, },
  // { title: '币种', width: 100, sorter: false, dataIndex: 'CYNM', key: 'CYNM', dispaly: true, canEdit: true, filter: false, },
];

const DataTable = dataTableCreate("LSCKDESR");
class LSCKDEBDSY extends Component {
  constructor(props) {
    super(props);
    this.state = {   
      dataChange: false
    };
  }
  componentDidMount() {
    this.props.dispatch({
      type: `LSCKDESR/setKeyName`,
      payload: { keyName: "ID", permID: 7026 }
    });
    this.loadData(this.props.lsType)
  }
  componentWillReceiveProps(nextProps) {
    if (nextProps.lsType !== this.props.lsType) {
      this.loadData(nextProps.lsType)
    }
  }
  loadData(lsType) {
    let sort = {
      field: "ABSJSR",
      order: "descend"
    }
    if (lsType === "1") {
      sort = {
        field: "JSR",
        order: "descend"
      }
    } else if (lsType === "2") {
      sort = {
        field: "JSR",
        order: "ascend"
      }
    }
    this.props.dispatch({
      type: `LSCKDESR/fetch`,
      payload: { daoName, page: 1, pageSize: 5, sorter: sort }
    });
  }
  render() {
    let { permID } = this.props
    return (
      <DataTable ref="RoleTable" daoName="LSCKDESR" columns={columns} permID={permID} canPage={false} canExport={false} canChange={false} canFilter={false} height={this.props.height} />
    )
  }
}
function mapStateToProps(state) {
  const { showEdit, record, selectedRowKeys, keyName } = state[daoName];
  const { userID, orgID, pOrgID, popedomTypes } = state["menus"];
  return {
    userID,
    orgID,
    pOrgID,
    popedomTypes,
    showEdit,
    selectedRowKeys,
    keyName,
    record,
  }
}
LSCKDEBDSY = connect(mapStateToProps)(LSCKDEBDSY)
export default LSCKDEBDSY;

